{#**
 * 2007-2020 PrestaShop SA and Contributors
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Open Software License (OSL 3.0)
 * that is bundled with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * https://opensource.org/licenses/OSL-3.0
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@prestashop.com so we can send you a copy immediately.
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade PrestaShop to newer
 * versions in the future. If you wish to customize PrestaShop for your
 * needs please refer to https://www.prestashop.com for more information.
 *
 * @author    PrestaShop SA <contact@prestashop.com>
 * @copyright 2007-2020 PrestaShop SA and Contributors
 * @license   https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
 * International Registered Trademark & Property of PrestaShop SA
 *#}

{% import 'PrestaShopBundle:Admin:macros.html.twig' as ps %}

{% block category_form_block %}
{{ form_start(categoryForm) }}
<div class="card">
  <h3 class="card-header">
    {{ 'Category'|trans({}, 'Admin.Catalog.Feature') }}
  </h3>
  <div class="card-block row">
    <div class="card-text">
      {{ form_errors(categoryForm) }}

      {{ ps.form_group_row(categoryForm.name, {}, {
        'label': 'Name'|trans({}, 'Admin.Global'),
        'help': 'Invalid characters:'|trans({}, 'Admin.Notifications.Info') ~ ' <>;=#{}'
      }) }}

      <div class="form-group row">
        {{ ps.label_with_help(('Displayed'|trans({}, 'Admin.Global')), ('Click on "Displayed" to index the category on your shop.'|trans({}, 'Admin.Catalog.Help'))) }}
        <div class="col-sm">
          {{ form_widget(categoryForm.active) }}
          <small class="form-text">
            {{ 'If you want a category to appear in the menu of your shop, go to [1]Modules > Module Manager[/1] and configure your menu module.'|trans({
              '[1]': '<a href="' ~ path('admin_module_manage') ~ '" class="_blank">',
              '[/1]': '</a>'
            }, 'Admin.Catalog.Help')|raw }}
          </small>
        </div>
      </div>

      {% if categoryForm.id_parent is defined %}
      <div class="form-group row">
        <label class="form-control-label">
          {{ 'Parent category'|trans({}, 'Admin.Catalog.Feature') }}
        </label>
        <div class="col-sm">
          {{ form_widget(categoryForm.id_parent) }}
        </div>
      </div>
      {% endif %}

      {{ ps.form_group_row(categoryForm.description, {}, {
        'label': 'Description'|trans({}, 'Admin.Global'),
        'help': 'Invalid characters:'|trans({}, 'Admin.Notifications.Info') ~ ' <>;=#{}'
      }) }}

      <div class="form-group row">
        <label class="form-control-label">
          {{ 'Category cover image'|trans({}, 'Admin.Catalog.Feature') }}
        </label>
        <div class="col-sm">
          {% include '@PrestaShop/Admin/Sell/Catalog/Categories/Blocks/cover_image.html.twig' %}

          {{ form_widget(categoryForm.cover_image) }}

          <small class="form-text">
            {{ 'This is the main image for your category, displayed in the category page. The category description will overlap this image and appear in its top-left corner.'|trans({}, 'Admin.Catalog.Help') }}
          </small>
        </div>
      </div>

      <div class="form-group row">
        <label class="form-control-label">
          {{ 'Category thumbnail'|trans({}, 'Admin.Catalog.Feature') }}
        </label>
        <div class="col-sm">
          {% include '@PrestaShop/Admin/Sell/Catalog/Categories/Blocks/thumbnail_image.html.twig' %}

          {{ form_widget(categoryForm.thumbnail_image) }}

          <small class="form-text">
            {{ 'Displays a small image in the parent category\'s page, if the theme allows it.'|trans({}, 'Admin.Catalog.Help') }}
          </small>
        </div>
      </div>

      <div class="form-group row">
        <label class="form-control-label">
          {{ 'Menu thumbnails'|trans({}, 'Admin.Catalog.Feature') }}
        </label>
        <div class="col-sm">
          {% include '@PrestaShop/Admin/Sell/Catalog/Categories/Blocks/menu_thumbnail_images.html.twig' %}

          {% if allowMenuThumbnailsUpload %}
            {{ form_widget(categoryForm.menu_thumbnail_images) }}
          {% else %}
            {{ form_widget(categoryForm.menu_thumbnail_images, {'attr': {'class': 'd-none'}}) }}

            <div class="alert alert-warning" role="alert">
              <p class="alert-text">
                {{ 'You have reached the limit (%s) of files to upload, please remove files to continue uploading'|trans({'%s': maxMenuThumbnails}, 'Admin.Catalog.Notification') }}
              </p>
            </div>
          {% endif %}
          <small class="form-text">
            {{ 'The category thumbnail appears in the menu as a small image representing the category, if the theme allows it.'|trans({}, 'Admin.Catalog.Help') }}
          </small>
        </div>
      </div>

      {{ renderhook('displayBackOfficeCategory') }}

      {% block category_tool_serp %}
        <div class="form-group row">
          <label class="form-control-label">{{ 'SEO preview'|trans({}, 'Admin.Global') }}</label>
          <div class="col-sm">
            <div id="serp-app" data-category-url="{{ categoryUrl }}"></div>
            <small class="form-text">
              {{ 'Here is a preview of how your page will appear in search engine results.'|trans({}, 'Admin.Global') }}
            </small>
          </div>
        </div>
      {% endblock %}

      <div class="form-group row">
        {{ ps.label_with_help(('Meta title'|trans({}, 'Admin.Global')), ('Invalid characters:'|trans({}, 'Admin.Notifications.Info') ~ ' <>;=#{}')) }}
        <div class="col-sm">
          {{ form_widget(categoryForm.meta_title) }}
        </div>
      </div>

      <div class="form-group row">
        {{ ps.label_with_help(('Meta description'|trans({}, 'Admin.Global')), ('Invalid characters:'|trans({}, 'Admin.Notifications.Info') ~ ' <>;=#{}')) }}
        <div class="col-sm">
          {{ form_widget(categoryForm.meta_description) }}
        </div>
      </div>

      {% set metaKeywordHelp %}
        {{ 'To add tags, click in the field, write something, and then press the "Enter" key.'|trans({}, 'Admin.Shopparameters.Help') }}
        {{ 'Invalid characters:'|trans({}, 'Admin.Notifications.Info') ~ ' <>;=#{}' }}
      {% endset %}

      {{ ps.form_group_row(categoryForm.meta_keyword, {}, {
        'label': 'Meta keywords'|trans({}, 'Admin.Global'),
        'help': metaKeywordHelp
      }) }}

      {{ ps.form_group_row(categoryForm.link_rewrite, {}, {
        'label': 'Friendly URL'|trans({}, 'Admin.Global'),
        'help': 'Only letters, numbers, underscore (_) and the minus (-) character are allowed.'|trans({}, 'Admin.Catalog.Help')
      }) }}

      {{ ps.form_group_row(categoryForm.group_association, {}, {
        'label': 'Group access'|trans({}, 'Admin.Catalog.Feature'),
        'help': 'Mark all of the customer groups which you would like to have access to this category.'|trans({}, 'Admin.Catalog.Help')
      }) }}

      <div class="form-group row">
        <label class="form-control-label"></label>
        <div class="col-sm">
          <div class="alert alert-info">
            <p class="mb-1">
              <strong>{{ 'You now have three default customer groups.'|trans({}, 'Admin.Catalog.Help') }}</strong>
            </p>

            <p>{{ '%group_name% - All people without a valid customer account.'|trans({'%group_name%': '<strong>' ~ defaultGroups.visitorsGroup.name ~ '</strong>'}, 'Admin.Catalog.Feature')|raw }}</p>
            <p>{{ '%group_name% - Customer who placed an order with the guest checkout.'|trans({'%group_name%': '<strong>' ~ defaultGroups.guestsGroup.name ~ '</strong>'}, 'Admin.Catalog.Feature')|raw }}</p>
            <p>{{ '%group_name% - All people who have created an account on this site.'|trans({'%group_name%': '<strong>' ~ defaultGroups.customersGroup.name ~ '</strong>'}, 'Admin.Catalog.Feature')|raw }}</p>
          </div>
        </div>
      </div>

      {% if categoryForm.shop_association is defined %}
        <div class="form-group row">
          <label class="form-control-label">
            {{ 'Shop association'|trans({}, 'Admin.Global') }}
          </label>
          <div class="col-sm">
            {{ form_widget(categoryForm.shop_association) }}
          </div>
        </div>
      {% endif %}

      {% block category_form_rest %}
        {{ form_rest(categoryForm) }}
      {% endblock %}
    </div>
  </div>
  <div class="card-footer">
    <a href="{{ path('admin_categories_index') }}" class="btn btn-outline-secondary">
      {{ 'Cancel'|trans({}, 'Admin.Actions') }}
    </a>
    <button class="btn btn-primary float-right">{{ 'Save'|trans({}, 'Admin.Actions') }}</button>
  </div>
</div>
{{ form_end(categoryForm) }}
{% endblock %}
